<?php
class tagApi extends core
{
	public function indexAction($arg)
	{
		$page	= isset($arg['page']) ? abs($arg['page']) : 1;
		$word	= $arg['word'];
		$offset	= 20;
		
		$columns= base::init('column')->fetchAll(array('wid'=>$arg['wid']));
		$num	= base::init('classified_tag')->getCount(array('tag'=>$word));
		$tags	= base::init('classified_tag')->fetchAll(array('tag'=>$word),'id desc',$offset,$offset*($page-1));
		
		$ids	= array_get_unique($tags, 'id');
		$list	= base::init('classified')->fetchAll(array('id'=>$ids),'id desc');
		$list	= base::init('classified')->getTempList($list, $columns);
		
		$template	= $this->template();
#$smarty->_tpl_vars['pager']['inttotal'],$smarty->_tpl_vars['row'],$smarty->_tpl_vars['thispage']


		$template->assign('row',$offset);
		$template->assign('repageUrl',urlencode($word).'-$i');
		$template->assign('thispage',$page);
		$template->assign('pager',array('inttotal'=>$num));
		
		
		$template->assign('listsize',5);
		$template->assign('list',$list);
		$template->assign('word',$word);
		$template->assign('num',$num);
		$template->assign('offset',$offset);
		$template->assign('wid',$arg['wid']);
		$template->assign('columns',$columns);
		
		$template->display('tag_index.php');
	}
}